package com.jie.message;

import com.jie.pojo.SingleChat;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public abstract class Message implements Serializable {

    public static Class<?> getMessageClass(int messageType) {
        return messageClasses.get(messageType);
    }

    private int sequenceId;

    private int messageType;

    public abstract int getMessageType();
    //单聊request
    public static final int SingleChatRequestMessage = 1;
    //群聊request
    public static final int GroupChatRequestMessage = 10;
    //心跳包
    public static final int PingMessage = 14;
    public static final int PangMessage = 15;
    private static final Map<Integer, Class<?>> messageClasses = new HashMap<>();

    static {
        messageClasses.put(SingleChatRequestMessage, SingleChat.class);
//        messageClasses.put(ChatResponseMessage, ChatResponseMessage.class);
//        messageClasses.put(GroupCreateRequestMessage, GroupCreateRequestMessage.class);
//        messageClasses.put(GroupCreateResponseMessage, GroupCreateResponseMessage.class);
//        messageClasses.put(GroupJoinRequestMessage, GroupJoinRequestMessage.class);
//        messageClasses.put(GroupJoinResponseMessage, GroupJoinResponseMessage.class);
//        messageClasses.put(GroupQuitRequestMessage, GroupQuitRequestMessage.class);
//        messageClasses.put(GroupQuitResponseMessage, GroupQuitResponseMessage.class);
//        messageClasses.put(GroupChatRequestMessage, GroupChatRequestMessage.class);
//        messageClasses.put(GroupChatResponseMessage, GroupChatResponseMessage.class);
//        messageClasses.put(GroupMembersRequestMessage, GroupMembersRequestMessage.class);
//        messageClasses.put(GroupMembersResponseMessage, GroupMembersResponseMessage.class);
//        messageClasses.put(PingMessage, PingMessage.class);
    }
}
